#ifndef _INCLUDE_H_
#define _INCLUDE_H_

	#include <stdlib.h>
	#include <stdio.h>
	#include <sys/types.h>
	#include <sys/stat.h>
	#include <fcntl.h>
	#include <time.h>
	#include <string.h>
	#include <rpc/types.h>
	#include <rpc/xdr.h>
	#include <rpc/rpc.h>
	#include <sys/time.h>
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netinet/in.h>
	#include <arpa/inet.h>
	#include <unistd.h>
	#include <netdb.h>
	#include <errno.h>
	#include <pthread.h>
	#include <sys/socket.h>


	#define PROGNUM 0x20001666
	#define VERSNUM 1
	#define PROCNUM 1

	#define SIZENAME 20
	#define SIZEIP 16
	#define BUFFERSIZE 4096

	#define RAWSIZE 2048
	
	#define ATTENTE int j; \
		for (j=0; j<10000; j++);
	
	typedef struct 
	{
		char name[SIZENAME];
		char ip[SIZEIP];
		int connected;  //TODO bool_t
	} Contact;

	typedef struct
	{
		char groupName[SIZENAME];
		int nbMembers;
		char ** members;
	} Group;

	typedef struct 
	{
		Contact me;
		int nbContacts;
		Contact * contacts;
		int nbGroups;
		Group * groups;
	} AdressBook;
	
	typedef struct
	{
		int timestamp;
		int type;
		char ipSender[SIZEIP];
		char ipReceiver[SIZEIP];
		char nameSender[SIZENAME];
		char nameReceiver[SIZENAME];
		int size;
		char * message;
	} Message;

	typedef struct 
	{
		int timestamp; 
		char ipSender[SIZEIP]; 
	} MessageReceived;

	typedef struct 
	{
		int nbMessageReceived;
		MessageReceived * list;
	} MessageReceivedList;

	enum 
	{
		STANDARD = 0, 		/* Message standard */ 
		SEARCH, 		/* Message dont on ne connait pas l'ip du destinataire */
		BACKSEARCH, 	/* Message réponse à un envoi vers inconnu pour établir le pont */ 
		CONNECTION,		/* Message d'arrivée sur le "serveur" */
		METOO, 			/* Message réponse à CONNECTION */
		DECONNECTION,	/* Message de sortie du "serveur" */ 
		ALREADY 		/* Message déjà reçu */
	};


	
	AdressBook adressBook;
	MessageReceivedList msgReceived;

#endif

